<template>
	<el-form ref="form" :model="form" label-width="80px">
		<el-form-item label="回款方式">
			<el-select v-model="remittanceWay" placeholder="请选择回款方式">
				<el-option label="微信" value="微信"></el-option>
				<el-option label="支付宝" value="支付宝"></el-option>
				<el-option label="现金" value="现金"></el-option>
				<el-option label="银行卡" value="银行卡"></el-option>
				<el-option label="云闪付" value="云闪付"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="回款金额">
		    <el-input v-model="amount" placeholder="请输入回款金额"></el-input>
		</el-form-item>
		<el-form-item label="回款比例">
		    <el-input v-model="rate" placeholder="自动同步" disabled="true"></el-input>
		</el-form-item>
		<el-form-item label="收款人">
		    <el-input v-model="payee" placeholder="请输入收款人"></el-input>
		</el-form-item>
		<el-form-item label="逾期天数">
		    <el-input v-model="overdueDays" placeholder="请输入逾期天数"></el-input>
		</el-form-item>
		<el-form-item label="备注">
			<el-input type="textarea" v-model="note" placeholder="请输入备注"></el-input>
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="onSubmit">新增回款</el-button>
			<el-button @click="back()">取消</el-button>
		</el-form-item>
	</el-form>
</template>

<script>
	export default {
		data() {
			return {
				userId: 0,
				customId: 0,
				contract: {},
				remittanceWay: '',
				amount: '',
				rate: '',
				payee: '',
				overdueDays: '',
				note:''
			}
		},
		onLoad(options) {
			this.userId = uni.getStorageSync('id')
			this.customId = options.customId
			console.log(this.userId + ' ' + this.customId);
			// 获取合同信息
			uni.request({
				url: 'http://localhost:8089/crmdemo/contract/queryContract', //仅为示例，并非真实接口地址。
				data: {
					userId: this.userId,
					customId: this.customId
				},
				success: (res) => {
					console.log(res);
					if (res.data.status == "000000") {
						this.contract = res.data.result
					} else {
						this.$modal.msgError("获取合同信息失败")
					}
				}
			});
		},
		methods: {
			onSubmit() {
				// 新增回款信息
				uni.request({
					url: 'http://localhost:8089/crmdemo/remittance/saveRemittance', //仅为示例，并非真实接口地址。
					data: {
						userId: this.userId,
						customId: this.customId,
						remittanceWay: this.remittanceWay,
						amount: this.amount,
						payee: this.payee,
						overdueDays: this.overdueDays,
						note: this.note
					},
					success: (res) => {
						console.log(res);
						if (res.data.status == "000000") {
							uni.showToast({
								title: "新增回款信息成功",
								duration: 2000
							})
							setTimeout(() => {
								uni.reLaunch({
									url: 'contractDetail?contractId='+this.contract.id
								})
							}, 2000)
						} else {
							this.$modal.msgError("新增回款信息失败")
						}
					}
				});
			},
			back(){
				uni.navigateTo({
					url: 'contractDetail?contractId='+this.contract.id
				})
			}
	
		}
	
	}
</script>

<style>
</style>